package org.apache.jsp.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.pomirkovany.beans.Item;

public final class item_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      org.pomirkovany.model.DataAccess dataAccess = null;
      synchronized (application) {
        dataAccess = (org.pomirkovany.model.DataAccess) _jspx_page_context.getAttribute("dataAccess", PageContext.APPLICATION_SCOPE);
        if (dataAccess == null){
          dataAccess = new org.pomirkovany.model.DataAccess();
          _jspx_page_context.setAttribute("dataAccess", dataAccess, PageContext.APPLICATION_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');

  String base = (String)application.getAttribute("base");
  String imageURL = (String)application.getAttribute("imageURL");
  
      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\r\n");
      out.write("  <title>Item details</title>\r\n");
      out.write("  <link rel=\"stylesheet\" href=\"/Cataloguer/css/cataloguer.css\" type=\"text/css\"/>\r\n");
      out.write("  </head>\r\n");
      out.write("<body>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "header.jsp", out, true);
      out.write('\r');
      out.write('\n');
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "SearchBar.jsp", out, true);
      out.write('\r');
      out.write('\n');
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "typesmenu.jsp", out, true);
      out.write("\r\n");
      out.write("<div class=\"content\">\r\n");
      out.write("  <h2>Details</h2>\r\n");

  try {
	  
    String itemId = request.getParameter("itemId");
    Item item = dataAccess.getItemDetails(itemId);
    if (item != null) {
		System.out.println("trouble ");
  
      out.write("\r\n");
      out.write("      <table>\r\n");
      out.write("        <tr>\r\n");
      out.write("          <td>\r\n");
      out.write("            <img src=\"");
      out.print((imageURL + item.getPicture()));
      out.write("\" width=\"62%\" height=\"62%\"/> \r\n");
      out.write("            </td>\r\n");
      out.write("          <td>\r\n");
      out.write("            <b>");
      out.print(item.getName());
      out.write("</b><br/>\r\n");
      out.write("            ");
      out.print(item.getAuthor());
      out.write("<br/>\r\n");
      out.write("            Rate: <img border=\"0\" src=\"images\\");
      out.print(item.getRate());
      out.write("s.png\" alt=\"no picture\" width=\"27%\" height=\"27%\" /><br/><br/><br/>\r\n");
      out.write("            Date: ");
      out.print(item.getDate());
      out.write("<br/>            \r\n");
      out.write("            Location: ");
      out.print(item.getLocation());
      out.write("<br/>\r\n");
      out.write("            Owner:");
      out.print(item.getOwner());
      out.write("<br/>\r\n");
      out.write("            Borrowed:<input type=\"checkbox\" name=\"vehicle\"\r\n");
      out.write("             ");
if(item.isBorrowed()){
      out.write("\r\n");
      out.write("             checked");
}
      out.write(" value=\"\" disabled /><br/><br/>\r\n");
      out.write("            Comment: ");
      out.print(item.getComment());
      out.write("<br/>\r\n");
      out.write("            \r\n");
      out.write("            \r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("        <tr>\r\n");
      out.write("          <td colspan=\"2\" align=\"right\">\r\n");
      out.write("            <a class=\"link1\"\r\n");
      out.write("              href=\"");
      out.print(base);
      out.write("?action=deleteItem&itemId=");
      out.print(item.getId());
      out.write("\">\r\n");
      out.write("              delete</a>\r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("           <tr>\r\n");
      out.write("          <td colspan=\"2\" align=\"right\">\r\n");
      out.write("            <a class=\"link1\"\r\n");
      out.write("              href=\"");
      out.print(base);
      out.write("?action=editItem&itemId=");
      out.print(item.getId());
      out.write("\">\r\n");
      out.write("              edit</a>\r\n");
      out.write("            </td>\r\n");
      out.write("          </tr>\r\n");
      out.write("        </table>\r\n");

      }
    }
  catch (Exception e) {
	
      out.write("<p class=\"error\">Invalid identifier!</p>");

	
    }
  
      out.write("\r\n");
      out.write("  </div>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
